package training;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;
// https://www.nowcoder.com/questionTerminal/ceb89f19187b4de3997d9cdef2d551e8
public class Day43_02 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            in.nextLine();
            String[] strings = new String[a];
            for(int i = 0; i < a; i++){
                strings[i] = in.nextLine();
            }
            TreeSet<String> treeSet = new TreeSet<>();
            for (int i = 0; i < strings.length; i++) {
                strings[i] = strings[i].replace("-","");
                char[] chars = strings[i].toCharArray();
                for (int j = 0; j < chars.length; j++) {
                    switch (chars[j]){
                        case 'A': case 'B': case 'C':
                            chars[j] = '2';
                            break;
                        case 'D': case 'E': case 'F':
                            chars[j] = '3';
                            break;
                        case 'G': case 'H': case 'I':
                            chars[j] = '4';
                            break;
                        case 'J': case 'K': case 'L':
                            chars[j] = '5';
                            break;
                        case 'M': case 'N': case 'O':
                            chars[j] = '6';
                            break;
                        case 'P': case 'R': case 'Q': case 'S':
                            chars[j] = '7';
                            break;
                        case 'T': case 'U': case 'V':
                            chars[j] = '8';
                            break;
                        case 'W': case 'X': case 'Y': case 'Z':
                            chars[j] = '9';
                            break;
                    }
                }
                treeSet.add(new String(chars));
            }
            for (String s: treeSet) {
                System.out.println(s.substring(0,3)+"-"+ s.substring(3));
            }
        }
    }
}
